<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of mobius</title>
  <meta name="keywords" content="mobius">
  <meta name="description" content="mobius(g,nverts) --- create a Mobius ladder graph">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="../index.html">matgraph</a> &gt; <a href="index.html">@graph</a> &gt; mobius.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for matgraph/@graph&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>mobius
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>mobius(g,nverts) --- create a Mobius ladder graph</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function mobius(g,nverts) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> mobius(g,nverts) --- create a Mobius ladder graph
 g is the graph to be written
 nverts is the number of vertices (must be even)</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="add.html" class="code" title="function add(g,i,j)">add</a>	add --- add edge(s) to the graph</li><li><a href="cycle.html" class="code" title="function cycle(g,n)">cycle</a>	cycle(g,n) --- create a cycle graph on n vertices</li><li><a href="embed.html" class="code" title="function embed(g,xy)">embed</a>	embed --- create an embedding for a graph</li><li><a href="rmxy.html" class="code" title="function rmxy(g)">rmxy</a>	rmxy(g) --- erase g's embedding</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function mobius(g,nverts)</a>
0002 <span class="comment">% mobius(g,nverts) --- create a Mobius ladder graph</span>
0003 <span class="comment">% g is the graph to be written</span>
0004 <span class="comment">% nverts is the number of vertices (must be even)</span>
0005 
0006 
0007 <span class="keyword">if</span> (mod(nverts,2)==1)
0008     error(<span class="string">'Number of vertices must be even'</span>)
0009 <span class="keyword">end</span>
0010 <span class="keyword">if</span> (nverts &lt; 6)
0011     error(<span class="string">'Number of vertices must be at least 6'</span>)
0012 <span class="keyword">end</span>
0013 
0014 n = nverts/2;
0015 <a href="cycle.html" class="code" title="function cycle(g,n)">cycle</a>(g,nverts)
0016 more_edges = zeros(n,2);
0017 <span class="keyword">for</span> v=1:n
0018     more_edges(v,:) = [v, v+n];
0019 <span class="keyword">end</span>
0020 
0021 <a href="add.html" class="code" title="function add(g,i,j)">add</a>(g,more_edges);
0022 
0023 <span class="comment">% create an embedding</span>
0024 <a href="rmxy.html" class="code" title="function rmxy(g)">rmxy</a>(g);
0025 
0026 <span class="comment">% inner ring of vertices</span>
0027 t = (0:n-1)*2*pi/n;
0028 x = n * cos(t)/6;
0029 y = n * sin(t)/6;
0030 xy1 = [x',y'];
0031 
0032 <span class="comment">% outer ring of vertices</span>
0033 x = (n+6)*cos(t)/6;
0034 y = (n+6)*sin(t)/6;
0035 xy2 = [x',y'];
0036 
0037 xy = [xy1;xy2];
0038 
0039 <span class="comment">% rotate slightly so crossing is symmetric across the x-axis</span>
0040 theta = pi/n;
0041 ct = cos(theta);
0042 st = sin(theta);
0043 rot = [ct,st; -st, ct];
0044 xy = xy*rot;
0045 
0046 <a href="embed.html" class="code" title="function embed(g,xy)">embed</a>(g,xy);</pre></div>
<hr><address>Generated on Fri 30-Apr-2010 07:51:16 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>